<?php 
	$subjectNumber = trim($_GET['subjectNumber']);
	$shiftCode = trim($_GET['shiftCode']);
	$vacancy = trim($_GET['vacancy']);
	$teacher = trim($_GET['teacher']);
	@$db = new mysqli('localhost','root','','fiuba');

	header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
	header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
	header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
	header ("Pragma: no-cache");
	//header ("Content-type: application/xml"); //uncomment this line if you plan to send XML

	//...................
	//echo "you should see now random numbers in your browser:".rand();
	
	if (mysqli_connect_errno())
	{
		//echo 'pucha error!';
		exit;
	}
	
	$query = "insert into fiuba.shift values
				(NULL,'$subjectNumber','$shiftCode','$vacancy','$teacher')";
	
	$db->query($query);		
	
	$query = "select shiftId from fiuba.shift where subjectNumber='$subjectNumber' and code='$shiftCode'";
	$result = $db->query($query);	
	
	$row = $result->fetch_assoc();
	echo trim($row['shiftId']);

	$db->close();
		
?>

 



